package wq.gdky005.util.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;

public class BroadcastReceiverHelper extends BroadcastReceiver {
	
	private Context context;
	private BroadcastReceiverHelper receiverHelper;
	
	//测试数据
//	NotificationManager notificationManager = null;
//	Notification notification = null;
	

	public BroadcastReceiverHelper(Context context) {
		this.context = context;
		this.receiverHelper = this;
	}

	/** 注册广播  */
	public void registerAction(String action) {
		IntentFilter filter = new IntentFilter();
		filter.addAction(action);
		context.registerReceiver(receiverHelper, filter);
	}


	@Override
	public void onReceive(Context context, Intent intent) {
		//这个Action 可以在这里写个方法，达到通用的目的
//		String action = "wq.gdky005";
//		String message =  intent.getStringExtra("name");
//		if (intent.getAction().equals(action)) {
//			notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
//			notification = new Notification(R.drawable.ic_launcher, "获取是谁发送的广播，测试", System.currentTimeMillis());
//			Intent it = new Intent(context, MainActivity.class);
//			PendingIntent contentIntent = PendingIntent.getActivity(context, 0, it, 0);
//			notification.setLatestEventInfo(context, "msg", message, contentIntent);
//			notificationManager.notify(0, notification);
//		
//		}
		
		Bundle bundle = intent.getBundleExtra("test");
	}

}
